

#import "NetWorkingHelper.h"
#import "XiaLa.h"
#import "MyApply.h"
@implementation NetWorkingHelper

+(NSMutableArray *)XiaLa{
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    NSString * strurl = [NSString stringWithFormat:@"%@/cmamsdata/customerCategoryController.do?method=listCustomerCategory",baseUrl];
    NSLog(@"strurl:%@",strurl);
    NSDictionary *resultDic= [NetWorking send:strurl method:POST requestHeader:nil requestBody:dic];
    NSLog(@"resultDic:%@",resultDic);
    NSDictionary * dic1 = [resultDic objectForKey:@"bizData"];
    NSArray * arr = [dic1 objectForKey:@"rows"];

    NSMutableArray * arr1 = [[NSMutableArray alloc]init];
    for (int i = 0; i < arr.count; i++) {
        
        NSDictionary * dic =  [arr objectAtIndex:i];
        XiaLa * model = [[XiaLa alloc]init];
        model.strcategoryName = [NSString stringWithFormat:@"%@",[dic objectForKey:@"categoryName"]];
        model.strcategoryId = [NSString stringWithFormat:@"%@",[dic objectForKey:@"categoryId"]];
        model.strpageSize = [NSString stringWithFormat:@"%@",[dic objectForKey:@"pageSize"]];
        model.strstartRowNum = [NSString stringWithFormat:@"%@",[dic objectForKey:@"startRowNum"]];
        model.strpageNum = [NSString stringWithFormat:@"%@",[dic objectForKey:@"pageNum"]];
        [arr1 addObject:model];
    }
    
    return arr1;
}

+(NSString *)ZhuCeWithuserName:(NSString *)userName  userPwd:(NSString *)userPwd categoryId:(NSString *)categoryId shopName:(NSString*)shopName shopArea:(NSString *)shopArea{
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:userName forKey:@"loginName"];
    [dic setObject:userPwd forKey:@"password"];
    [dic setObject:categoryId forKey:@"categoryId"];
    [dic setObject:shopName forKey:@"shopName"];
    [dic setObject:shopArea forKey:@"shopArea"];
    NSString * strurl = [NSString stringWithFormat:@"%@/cmamsdata/customerController.do?method=ajaxInsertCustomer",baseUrl];
    NSDictionary *resultDic= [NetWorking send:strurl method:POST requestHeader:nil requestBody:dic];
    NSLog(@"%@",resultDic);
    NSString * str = [NSString stringWithFormat:@"%@",[resultDic objectForKey:@"message"] ];
   
    
    return str;
}

//用户登录方法
+(YongHuXinXi *)DengLuWithuserName:(NSString *)userName  userPwd:(NSString *)userPwd {
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:userName forKey:@"userName"];
    [dic setObject:userPwd forKey:@"userPwd"];

    NSString * strurl = [NSString stringWithFormat:@"%@/cmamsdata/loginController.do?method=login",baseUrl];
    NSDictionary *resultDic= [NetWorking send:strurl method:POST requestHeader:nil requestBody:dic];
    NSLog(@"%@",resultDic);

    YongHuXinXi * model = [[YongHuXinXi alloc]init];
    model.message = [NSString stringWithFormat:@"%@",[resultDic objectForKey:@"message"]];
    if ([model.message isEqualToString:@"0"]) {
        NSDictionary * dic1 = [resultDic objectForKey:@"bizData"];
        
        model.strloginTime = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"loginTime"]];
        model.struserIp = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"userIp"]];
        model.strpageNum = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"pageNum"]];
        model.strpageSize = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"pageSize"]];
        model.strvisitTime = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"visitTime"]];
        model.strstartRowNum = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"startRowNum"]];
        model.struserId = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"userId"]];
        model.strloginName = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"loginName"]];
        model.strpassword = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"password"]];
        model.strshopArea = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"shopArea"]];
        model.strcategoryId = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"categoryId"]];
        model.strsessionId = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"sessionId"]];
        model.strshopName = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"shopName"]];

    }
    return model;
}


+(NSString *)XiuGaiGeRenXinXiWithcustomerId:(NSString *)customerId  categoryId:(NSString *)categoryId shopName:(NSString *)shopName  shopArea:(NSString *)shopArea{
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:customerId forKey:@"customerId"];
    [dic setObject:categoryId forKey:@"categoryId"];
    [dic setObject:shopName forKey:@"shopName"];
    [dic setObject:shopArea forKey:@"shopArea"];
    NSLog(@"customerId:%@",customerId);
    NSLog(@"categoryId:%@",categoryId);
    NSLog(@"shopName:%@",shopName);
    NSLog(@"shopArea:%@",shopArea);
   
    NSString * strurl = [NSString stringWithFormat:@"%@/cmamsdata/customerController.do?method=ajaxUpdateCustomer",baseUrl];
    NSDictionary *resultDic= [NetWorking send:strurl method:POST requestHeader:nil requestBody:dic];
    NSLog(@"%@",resultDic);
    NSString * str = [resultDic objectForKey:@"message"];
   
    return str;
}

+(NSString *)XiuGaiMiMaWithuserId:(NSString *)userId  passwd:(NSString *)passwd resetPasswd:(NSString *)resetPasswd  {
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:userId forKey:@"userId"];
    [dic setObject:passwd forKey:@"passwd"];
    [dic setObject:resetPasswd forKey:@"resetPasswd"];

    NSString * strurl = [NSString stringWithFormat:@"%@/cmamsdata/userController.do?method=ajaxUpdateUserPasswd",baseUrl];
    NSDictionary *resultDic= [NetWorking send:strurl method:POST requestHeader:nil requestBody:dic];
    NSLog(@"%@",resultDic);
    NSString * str = [resultDic objectForKey:@"message"];
    
    return str;
}


+(NSMutableArray *)MyApplyWithcategoryId:(NSString *)categoryId  {
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:categoryId forKey:@"categoryId"];
    [dic setObject:@"1" forKey:@"system"];
   
    NSString * strurl = [NSString stringWithFormat:@"%@/cmamsdata/customerCategoryController.do?method=ajaxListCategoryApp",baseUrl];
    NSDictionary *resultDic= [NetWorking send:strurl method:POST requestHeader:nil requestBody:dic];
    NSLog(@"%@",resultDic);
    NSArray * arr = [resultDic objectForKey:@"bizData"];
    NSMutableArray * arr1 = [[NSMutableArray alloc]init];
    for (int i = 0; i < arr.count; i++) {
        NSDictionary * dic1 = [arr objectAtIndex:i];
        MyApply * model = [[MyApply alloc]init];
        model.strappPath = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"appPath"]];
        model.strappId = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"appId"]];
        model.strappIcon = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"appIcon"]];
        model.strappPackage = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"appPackage"]];
        model.strappName = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"appName"]];
        model.strappCategory = [NSString stringWithFormat:@"%@",[dic1 objectForKey:@"appCategory"]];
        [arr1 addObject:model];
    }
    
    return arr1;
}

@end
